package chapter08

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/9 21:35
  * @history:
  *          1.2019/1/9 created by chuhaitao
  */
object TestApplay {

  //直接使用apply方法创建对象
  var pig = Pig.apply("bom")


}

class Pig(pName: String) {
  var name: String = pName
}

object Pig {
  //编写一个apply方法
  def apply(pName: String): Pig = new Pig(pName)

  def apply(): Pig = new Pig("jack")
}